<template>
  <a-config-provider :locale="zhCN">
    <div id="app">
      <router-view/>
    </div>
  </a-config-provider>
</template>

<script>
import zhCN from 'ant-design-vue/lib/locale-provider/zh_CN'
import moment from 'moment'
import 'moment/locale/zh-cn'

moment.locale('zh-cn')
export default {
  data () {
    return {
      zhCN,
      ntkoListener: null
    }
  },
  mounted () {
    if (!window.config.VUE_APP_IC_CLOSE) {
      // charles 消息中心握手连接
      const param = {
        // 必填：消息中心服务器地址
        serverIp: window.config.VUE_APP_IC_SERVER_IP,
        // 必填：消息中心服务器端口
        serverPort: window.config.VUE_APP_IC_SERVER_PORT,
        // 必填：需要消息中心先新建并拿到标识(管理端直接初始化)
        appId: '402885c47f915d0a017f919cba9c0013',
        // 选填：分组消息发送标识
        groupId: 'IC-DAP5-ZRZY',
        // 选填：用户消息发送标识(用户登录名)
        userId: null,
        // 选填：单机标识
        singleId: null
      }
    }
    this.ntkoListener = this.ntkoMessageListener()
    if (window.opener && window.opener.$distApp) {
      window.opener.$distApp.eventHub.$on('_USER_LOGOUT_', () => {
        window.close()
      })
    }

    this.Event.$on('_DEMO_MSG', () => {
      this.$message.success('demo $message', 5)
    })
  },
  methods: {
    ntkoMessageListener () {
      const _this = this

      function listener (event) {
        if (event.data.type === 'FROM_NTKO_CONTEXT_PAGE') {
          const textJson = JSON.parse(event.data.text)
          if (textJson.ntkoData.close) {
            _this.Event.$emit('NTKO_CLOSE')
          }
        }
      }

      window.addEventListener('message', listener)
      return listener
    }
  },
  destroyed () {
    if (this.ntkoListener) {
      window.removeEventListener('message', this.ntkoListener)
    }
  }
}
</script>

<style lang="less">
#app {
  font-family: MicrosoftYaHei;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  height: 100%;

  .ant-btn {
    border-radius: 2px;
  }

  .ant-btn-danger:hover {
    background-color: #ff4d4fbd;
  }

  .ant-btn-primary[disabled], .ant-btn-primary[disabled]:hover, .ant-btn-primary[disabled]:focus, .ant-btn-primary[disabled]:active {
    background: #f5f5f5;
  }

  .ant-btn-danger[disabled], .ant-btn-danger[disabled]:hover, .ant-btn-danger[disabled]:focus, .ant-btn-danger[disabled]:active {
    background: #f5f5f5;
  }

  .dist-box-table {
    height: 100%;
    /*设置偶数行颜色*/

    .ant-table-tbody {
      > tr:nth-child(even) {
        background: #ffffff;
      }
    }

    .ant-table {
      width: 100%;
    }

    .ant-table-placeholder {
      height: 100%;
      width: 100%;
    }

    .ant-spin-nested-loading {
      height: 100%;
      width: 100%;
    }

    .ant-spin-container {
      height: 100%;
      width: 100%;
      display: flex;
      flex-wrap: wrap;
      align-content: flex-start;
    }

    .ant-pagination-total-text {
      float: left;
    }

    .ant-table-pagination {
      width: 100%;
      text-align: right;
      align-self: flex-end !important;
    }

    .ant-table-thead > tr > th {
      background: #eceded;
      border-right: 1px solid #c0cad3;
      border-bottom: 1px solid #c0cad3;
      height: 50px;
      //系统表格表头都居中
      text-align: center !important;

      &:last-child {
        border-right: 1px solid #f0f0f0;
      }
    }

    .ant-table-tbody > tr > td {
      border-right: 1px solid #c0cad3;
      border-bottom: 1px solid #c0cad3;
      height: 50px;
      text-overflow: ellipsis !important;
      overflow: hidden;

      &:last-child {
        border-right: 1px solid #dbdde0;
      }
    }
  }

  .title {
    text-align: center;
    position: relative;
    // margin-left: 113px;
    margin-left: 20px;
  }

  .ant-table-column-title {
    font-size: 13px;
    font-weight: bold;
  }

  .ant-menu-item-selected {
    font-weight: bold;
  }

  .ant-tabs-tab-active {
    font-weight: bold;
    color: #2BAEF2;
  }
}

.ant-collapse {
  border: none !important;

  .ant-collapse-item > .ant-collapse-header {
    background: #e8f4fa;
    font-family: MicrosoftYaHei, MicrosoftYaHei-Bold;
    font-weight: 700;
    color: #098bd3 !important;
    border-bottom: none !important;
  }
}

.ant-collapse-content {
  border: 1px solid #b1ddff;
}

header > .ant-menu {
  text-align: center;
}

.ant-modal-content {
  max-height: 100% !important;

  .ant-modal-close {
    color: #ffffff;
  }

  .ant-modal-header {
    background: linear-gradient(270deg, #05b3cb, #2caef3 100%);

    .ant-modal-title {
      color: #ffffff;
    }
  }
}

#nav {
  padding: 30px;

  a {
    font-weight: bold;
    color: #2c3e50;

    &.router-link-exact-active {
      color: #42b983;
    }
  }
}

#nprogress .bar {
  top: auto !important;
  bottom: 0 !important;
  height: 5px !important;
}

.cursor_pointer {
  cursor: pointer
}

.border-left-f3eaea {
  border-left: 1px solid #f3eaea
}

.border-right-f3eaea {
  border-right: 1px solid #f3eaea
}

.switch-icon {
  position: absolute;
  font-size: 20px;
  color: white;
  margin-left: 11px;
  margin-top: 10px;
}

button {
  cursor: pointer;
}

.boldTypes {
  font-weight: bolder;
}

.select-boldTypes {
  background-color: #e6f7ff;
  font-weight: bolder;
}

.ql-disabled {
  background-color: #f5f5f5;
}

.ant-spin-container:after {
  display: none;
}

.bg-white {
  .ant-pagination-item a {
    color: #999999;
  }
}
</style>
